package com.dfbz.demo01;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo03_Calendar转Date {
    public static void main(String[] args) {

        // 创建一个日历
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR,1999);
        calendar.set(Calendar.MONTH,7);


        // 将日历转换为Date对象
        Date date = calendar.getTime();

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String strDate = sdf.format(date);
        System.out.println(strDate);

//        long timeInMillis = calendar.getTimeInMillis();
//        System.out.println(timeInMillis);

    }
}
